package cn.melon.base;

import cn.melon.mod.login.UserInfo;

/**
 * 此类为各个模块的回复请求基类, 此类是由{@link cn.melon.bz.ClientThread#run()}调用<br><p>
 *              该类有一个必须实现的函数{@link #onResponse()}
 * @ClassName: BaseController
 * @author corvo
 *                  
 */
public abstract class BaseController {

    /**
     * request参数为客户端发送的请求, 为json字符串
     */
    private String request;
    
    /**
     * response 为该类响应后的结果, 为json字符串
     */
    private String response;
    
    /**
     * 各个模块需要获取用户信息
     */
    private UserInfo UserInfo;

    public UserInfo getUserInfo() {
        return UserInfo;
    }

    public void setUserInfo(UserInfo userInfo) {
        UserInfo = userInfo;
    }

    /**
     * 响应函数
     */
    public abstract void onResponse();

    public String getResponse() {
        return response;
    }

    public void setResponse(String response) {
        this.response = response;
    }

    public BaseController(String request) {
        this.request = request;
    }

    public String getRequest() {
        return request;
    }

    public void setRequest(String request) {
        this.request = request;
    }
    
    /**
     * 调用response, 产生返回结果
     */
    public synchronized void makeResponse() {
        onResponse();
    }

}
